﻿@model OPM.Models.OfficerProfile

@using OPM.Class;
@using System.Web.Mvc;

@{
 
    Layout = "~/Views/Shared/_LayoutPopup.cshtml";
}

<link rel="stylesheet" type="text/css" href="/js/colorbox-master/colorbox.css">
<script src="/js/colorbox-master/jquery.colorbox-min.js"></script>

@using (Html.BeginForm("Profile", "OfficerProfileLogs", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    <div class="service_search_header">
        <div class="service_title">@Multi.Profile</div>
        <div onclick="openActionBox();" class="profile-action p-Absolute"></div>
        <div class="profile-action-box dNone p-Absolute">
            <div class="profile-action-box1"><a href="@Url.Action("ProfileLogs", "OfficerProfileLogs")?a=log" data-block="log" class="callBox">@Multi.History</a></div>
            <div class="profile-action-box2"><a href="@Url.Action("ResetPassword", "Account")?a=resetPassword" onclick="parent.callcolorboxResetPass($(this).attr('href')); return false;">@Multi.ResetPassword</a></div>
        </div>
    </div>
    <div class="service_box_table" style="padding: 15px 33px 5px 75px;">
        <table id="profile_table" class="profile_table2">
            <tr>
                <td>@Multi.title_name</td>
                <td>:</td>
                <td>
                @Html.TextBoxFor(m => m.salutation_th)
                @Html.ValidationMessageFor(m => m.salutation_th)
                </td>
            </tr>
            <tr>
                <td>@Multi.name</td>
                <td>:</td>
                <td>
                @Html.TextBoxFor(m => m.firstname_th)
                @Html.ValidationMessageFor(m => m.firstname_th)
                </td>
            </tr>
            <tr>
                <td>@Multi.lastname</td>
                <td>:</td>
                <td>
                @Html.TextBoxFor(m => m.lastname_th)
                @Html.ValidationMessageFor(m => m.lastname_th)
                </td>
            </tr>
            <tr>
                <td>Title</td>
                <td>:</td>
                <td>
                @Html.TextBoxFor(m => m.salutation_en)
                @Html.ValidationMessageFor(m => m.salutation_en)
                </td>
            </tr>
            <tr>
                <td>Name</td>
                <td>:</td>
                <td>
                @Html.TextBoxFor(m => m.firstname_en)
                @Html.ValidationMessageFor(m => m.firstname_en)
                </td>
            </tr>
            <tr>
                <td>Surname</td>
                <td>:</td>
                <td>
                @Html.TextBoxFor(m => m.lastname_en)
                @Html.ValidationMessageFor(m => m.lastname_en)
                </td>
            </tr>
            <tr>
                <td>@Multi.gender</td>
                <td>:</td>
                <td>
                    @Html.DropDownListFor(m => m.gender_id, (SelectList)ViewBag.listOfGender, "เลือกเพศ")
                    @Html.ValidationMessageFor(m => m.gender_id)
                </td>
            </tr>
            <tr>
                <td>@Multi.citizen_id</td>
                <td>:</td>
                <td>
                @Html.TextBoxFor(m => m.citizen_id)
                @Html.ValidationMessageFor(m => m.citizen_id)
                </td>
            </tr>
            <tr>
                <td>@Multi.Organization</td>
                <td>:</td>
                <td>
                    @Html.HiddenFor(m => m.org_id)
                   @Html.TextBoxFor(m => m.org_text)
                   <span id="block_profile"></span>
                    <a href="@Url.Action("LovOrganization2", "Complaint")?a=profile" data-block="profile"  
                        >
                        <div class="avatar_add_btn"></div>
                    </a> 
                    <div class="avatar_del_btn" onclick="deleteOrg"></div>
                </td>

            </tr>
            <tr>
                <td>@Multi.Positions</td>
                <td>:</td>
                <td>
                @Html.TextBoxFor(m => m.position)
                @Html.ValidationMessageFor(m => m.position)
                </td>
            </tr>
            <tr>
                <td>@Multi.tel</td>
                <td>:</td>
                <td>
                @Html.TextBoxFor(m => m.phone)
                @Html.ValidationMessageFor(m => m.phone)
                </td>
            </tr>
            <tr>
                <td>@Multi.mobile</td>
                <td>:</td>
                <td>
                @Html.TextBoxFor(m => m.mobile)
                @Html.ValidationMessageFor(m => m.mobile)
                </td>
            </tr>
            <tr>
                <td>@Multi.email</td>
                <td>:</td>
                <td>
                @Html.TextBoxFor(m => m.email)
                @Html.ValidationMessageFor(m => m.email)
                </td>
            </tr>
            <tr>
                <td>@Multi.OtherName</td>
                <td>:</td>
                <td>
                @Html.TextBoxFor(m => m.other_name)
                @Html.ValidationMessageFor(m => m.other_name)
                </td>
            </tr>
            <tr>
                <td>@Multi.avatar</td>
                <td>:</td>
                <td>
                    <img id="avartar" src="@Model.picture_profile" style="max-width:100%"/>
                    <br/>
                    <input type="file" id="file" name="file" accept="image/*" /> 
                </td>
            </tr>
            <tr>
                <td>@Multi.language</td>
                <td>:</td>
                <td>
                    @{
    List<SelectListItem> listItems_lang = new List<SelectListItem>();
    listItems_lang.Add(new SelectListItem
    {
        Text = "ไทย",
        Value = "TH",
        Selected = true
    });
    listItems_lang.Add(new SelectListItem
    {
        Text = "อังกฤษ",
        Value = "EN"

    });
                   }

                    @Html.DropDownListFor(model => model.default_language, listItems_lang)

                </td>
            </tr>
            <tr>
                <td>จำนวนการแสดงผล</td>
                <td>:</td>
                <td>
                      @{
    List<SelectListItem> listItems_rowpage = new List<SelectListItem>();
    listItems_rowpage.Add(new SelectListItem
    {
        Text = "10",
        Value = "10",
        Selected = true
    });
    listItems_rowpage.Add(new SelectListItem
    {
        Text = "20",
        Value = "20",
        Selected = true
    });
    listItems_rowpage.Add(new SelectListItem
    {
        Text = "30",
        Value = "30",
        Selected = true
    });
    listItems_rowpage.Add(new SelectListItem
    {
        Text = "40",
        Value = "40",
        Selected = true
    });
    listItems_rowpage.Add(new SelectListItem
    {
        Text = "50",
        Value = "50"

    });
                                }
                   
                    @Html.DropDownListFor(model => model.row_per_page, listItems_rowpage)
                </td>
            </tr>

            <tr>
                <td>@Multi.password</td>
                <td>:</td>
                <td>
                    @Html.TextBoxFor(m => m.password) <br /> 
                   <div style="color:red;"> @TempData["NonSuccess"]</div>
                </td>
            </tr>

        </table>

            @Html.HiddenFor(m => m.birthday)
            @Html.HiddenFor(m => m.address)
            @Html.HiddenFor(m => m.subdistrict_id)
            @Html.HiddenFor(m => m.district_id)
            @Html.HiddenFor(m => m.province_id)
            @Html.HiddenFor(m => m.postcode)

    </div>
    <div class="BoxServiceBottom">
        <div class="BoxServiceActionPrev floatL" onclick="parent.$.colorbox.close();">@Multi.close</div>
        <div class="NoteProfie floatL">
            @Multi.ProfileDescription
        </div>
        <input class="BoxServiceActionNext floatR" type="submit" value="@Multi.edit" onclick="return CheckData();" />
        <div class="clear"></div>
    </div>
    
}

<div class="dNone">
    <div id="inline_content">
        <div class="SaveSuccess">
            <div class="SaveSuccessTab1">@Multi.edit_success</div>
            <div class="SaveSuccessTab3" onclick="$.colorbox.close();">@Multi.finish</div>
        </div>
    </div>
</div>

<script>


    $(document).ready(function () {
        $('#block_profile').html(parent.temp_text);
    });
    function CheckData() {
        var boolAllowSubmit = true;
        var salutation_th = $("#salutation_th").val();
        var firstname_th = $("#firstname_th").val();
        var lastname_th = $("#lastname_th").val();
        var gender_id = $("#gender_id").val();
        var citizen_id = $("#citizen_id").val();
        var org_id = $("#org_id").val();
        var position = $("#position").val();
        var phone = $("#phone").val();
        var mobile = $("#mobile").val();
        var email = $("#email").val();
        var other_name = $("#other_name").val();
        var default_language = $("#default_language").val();
        var row_per_page = $("#row_per_page").val();

        if (salutation_th == "") {
            alert("ระบุคำนำหน้าชื่อ");
            boolAllowSubmit = false;
        }
        else if (firstname_th == "") {
            alert("ระบุชื่อ");
            boolAllowSubmit = false;
        } else if (lastname_th == "") {
            alert("ระบุนามสกุล");
            boolAllowSubmit = false;
        } else if (gender_id == "") {
            alert("ระบุเพศ");
            boolAllowSubmit = false;
        }
        else if (citizen_id == "") {
            alert("ระบุรหัสบัตรประจำตัวประชาชน");
            boolAllowSubmit = false;
        }
        else if (org_id == null) {
            alert("ระบุหน่วยงาน");
            boolAllowSubmit = false;
        }
        else if (position == "") {
            alert("ระบุตำแหน่ง");
            boolAllowSubmit = false;
        }
        else if (phone == "") {
            alert("ระบุโทรศัพท์");
            boolAllowSubmit = false;
        }
        else if (mobile == "") {
            alert("ระบมือถือ");
            boolAllowSubmit = false;
        } else if (email == "") {
            alert("ระบุอีเมล์");
            boolAllowSubmit = false;
        }
        else if (default_language == "") {
            alert("ระบุภาษา");
            boolAllowSubmit = false;
        }
        else if (row_per_page == "") {
            alert("ระบุจำนวนหน้า");
            boolAllowSubmit = false;
        }
        return boolAllowSubmit;
    }

    function openActionBox() {
        $('.profile-action-box').hide(function () {
            $('.profile-action-box').show('blind');
        });
    }

    function savedataform() {
        $.colorbox({
            inline: true,
            width: "50%",
            href: "#inline_content",
            fastIframe: false,
            onClosed: function () {

            }
        });
    }


    function deleteOrg() {
        $("#org_text").val('')
    }

</script>

